package com.lindroy.androidplayer.ui.adapter

import androidx.lifecycle.LifecycleOwner
import androidx.recyclerview.widget.DiffUtil
import com.lindroy.androidplayer.base.adapter.BasePagingAdapter
import com.lindroy.androidplayer.databinding.CollectedArticleItemBinding
import com.lindroy.androidplayer.viewmodels.CollectedArticleItemViewModel

/**
 * @author Lin
 * @date 2022/2/20
 * @function 我的收藏-文章
 */
class CollectedArticleAdapter(owner: LifecycleOwner) :
    BasePagingAdapter<CollectedArticleItemViewModel, CollectedArticleItemBinding>(owner,
        object : DiffUtil.ItemCallback<CollectedArticleItemViewModel>() {
            override fun areItemsTheSame(
                oldItem: CollectedArticleItemViewModel,
                newItem: CollectedArticleItemViewModel
            ): Boolean = oldItem.id == newItem.id

            override fun areContentsTheSame(
                oldItem: CollectedArticleItemViewModel,
                newItem: CollectedArticleItemViewModel
            ): Boolean = oldItem.id == newItem.id

        }) {
    override fun CollectedArticleItemBinding.onBindViewHolder(
        item: CollectedArticleItemViewModel?,
        position: Int
    ) {
        vm = item
    }
}